package com.lijiaxing.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * {code
 *
 * @description 响应对象
 * }
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class Result<T> {
    private T data;
    private String msg;
    private int code;

    public static Result<String> success() {
        return new Result<String>("", "操作成功", 0);
    }

    public static <E> Result<E> success(E data) {
        return new Result<>(data, "操作成功", 1);
    }

    public static <E> Result<E> success(E data, String msg) {
        return new Result<>(data, msg, 1);
    }

    public static <E> Result<E> error() {
        return new Result<>(null, "操作失败", -1);
    }

    public static <E> Result<E> error(E data) {
        return new Result<>(data, "操作失败", -1);
    }

    public static <E> Result<E> error(E data, String msg) {
        return new Result<>(data, msg, -1);
    }

}
